const flecs = @import("zflecs");
const rl = @import("raylib");
const std = @import("std");
const zlua = @import("zlua");
const Lua = zlua.Lua;
// const HashMap = std.StringHashMap(comptime V: type)
const Game = @import("./game.zig").Game;

// defines
pub const LuaVm = struct {
    vm: *Lua,
};
pub const GameConfig = struct {
    fps: u16,
    fixed_fps: u16,
};
pub const GameState = struct {
    is_active: bool = true,
    duration_per_frame: f32 = 0,
    acc_duration: f32 = 0,
};
pub const Translation = rl.Vector2;
pub const Rotate = i32;
pub const Scale = struct {
    x: f32,
    y: f32,
    const Self = @This();
    pub fn one(self: *Self) void {
        self.x = 1;
        self.y = 1;
    }
};
pub const CollisionShapeType = enum {
    Rectangle,
    Circle,
};
pub const Collision = union(CollisionShapeType) {
    Rectangle: rl.Rectangle,
    Circle: struct { center: rl.Vector2, radius: f32 },
};

// runtime infos
pub const ComponentInfo = struct {
    id: u64,
    name: [*:0]const u8,
};

// pub fn register_component(game: *Game, comptime Comp: type) ComponentInfo {
//     flecs.COMPONENT(game.ecs_world, Comp);
//     const id = flecs.id(Comp);
//     return .{
//         .id = id,
//         .name = flecs.id_str(game.ecs_world, id).?,
//     };
// }

pub const ComponentInfos = struct {
    TranslationComp: ComponentInfo,
    RotateComp: ComponentInfo,
    ScaleComp: ComponentInfo,
    CollisionComp: ComponentInfo,
};

pub const PrefabInfos = struct {
    Actor: flecs.entity_t,
};
// isa(e) ecs_pair(EcsIsA, e)
// pub fn init_prefabs(game: *Game) PrefabInfos {
//     // _ = game;
//     const world = game.ecs_world;
//     const actor = flecs.new_prefab(world, "Actor");
//     flecs.set(world, actor, Translation, .{ .x = 50, .y = 50 });
//     flecs.set(world, actor, Scale, .{ .x = 1, .y = 1 });
//     flecs.set(world, actor, Rotate, 0);
//     flecs.set(world, actor, Collision, .{
//         .Rectangle = .{
//             .x = 0,
//             .y = 0,
//             .width = 50,
//             .height = 50,
//         },
//     });
//     return .{
//         .Actor = actor,
//     };
// }

// pub fn init_components(game: *Game) ComponentInfos {
//     return .{
//         .TranslationComp = register_component(game, Translation),
//         .RotateComp = register_component(game, Rotate),
//         .ScaleComp = register_component(game, Scale),
//         .CollisionComp = register_component(game, Collision),
//     };
// }
